﻿@{
    Layout = null;
}
@using ZBJF.Warranty.WebProvider.AdminPemission
@using ZBJF.Warranty.Common.Enums.InsuranceWarranty
@model List<ZBJF.Warranty.Model.ViewModel.InfoCollect.InfoCollectSelectModel>
@foreach (var item in Model.Where(m => m.CollectWithType == ViewBag.Pid))
{
    if (Model.Where(m => m.CollectWithType == item.ID).Count() > 0 || ViewBag.Pid != 0)
    {
        int layer = ViewBag.Layer;
        var paddingLeft = 30 * layer + "px";
        <tr layer="@layer" @(ViewBag.Pid==0?"class=firstParent":"")>
            <td class="category">
                @if (Model.Where(m => m.CollectWithType == item.ID).Count() > 0)
                {
                    <span class="close" attr-id="close" style="float:right;margin-left: @paddingLeft" onclick="categoryTree(this, @layer)"></span>
                }
                else
                {
                    <span attr-id="close" style="float:right;margin-left: @paddingLeft"></span>
                }
            </td>
            <td @(ViewBag.Pid==0?"style=font-weight:bold":"")>@item.InfoCollectName</td>
            <td>@item.InfoCollectCategoryName</td>
            <td>
                @if (item.CollectWithType < 0)
                {
                    <input type="text" value="" class="infoCollectNumber" onkeyup = "onlyInputInt(this)" maxlength="2"/>
                }
            </td>
            <td>
                @if (item.CollectWithType < 0)
                {
                    <input type="checkbox" value="@item.ID" class="infoCollectIsMust"  />
                }
            </td>
            <td>
                @if (item.CollectWithType < 0)
                {
                    <input type="checkbox" value="@item.ID" class="useInfoCollect" />
                }
            </td>
        </tr>
        var childMenu = Model.Where(m => m.CollectWithType == item.ID).ToList();
        layer = layer + 1;
        if (childMenu.Any())
        {
            @Html.Action("InfoCollectSelect", "InsuranceProducts", new { listPage = Model, pid = item.ID, layer = layer })
        }
        layer = layer - 1;
    }
}